/*************************************************************************
	> File Name: P1679.cpp
	> Author: yufangze
	> Mail: 2224590123@qq.com
	> Created Time: 2025-04-16 17:50:11
 ************************************************************************/

#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define MAX_N 100000

int dp[MAX_N + 5];

int main() {
    int m;
    cin >> m;
    for (int i = 0; i <= m; i++) dp[i] = i;
    for (int i = 1, I = pow(m, 1.0 / 4); i <= I; i++) {
        for (int j = 1; j <= m; j++) {
            if (j - pow(i, 4) >= 0) {
                dp[j] = min(dp[j], dp[j - int(pow(i, 4))] + 1);
            }
        }
    }
    cout << dp[m] << endl;
    return 0;
}
